local skel = fk.CreateSkill {
  name = "lb__yingbin",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable {
  ["lb__yingbin"] = "迎宾",
  [":lb__yingbin"] = "<b>锁定技</b>，每名角色的准备阶段，其选择一项：<br>" ..
      "1.摸一张牌并跳过出牌阶段；<br>" ..
      "2弃置一张牌。<br>" ..
      "然后其于本回合的额定弃牌阶段后获得一个出牌阶段，若为你，此阶段其他角色不能使用或打出手牌。",

  ["#lb__yingbin"] = "迎宾：你可以弃置一张牌，或取消后摸一张牌并跳过出牌阶段",

  ["@@lb__yingbin-phase"] = "迎宾",

  ["$lb__yingbin1"] = "这次一定让您满意！",
  ["$lb__yingbin2"] = "这位客人，请别生气… ",
  ["$lb__yingbin3"] = "给您添麻烦了…",
}



skel:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and data.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if target:isNude() or #room:askToDiscard(target, {
          min_num = 1,
          max_num = 1,
          include_equip = true,
          skill_name = skel.name,
          prompt = "#lb__yingbin",
        }) == 0 then
      target:drawCards(1, skel.name)
      target:skip(Player.Play)
    end
    local turn = room.logic:getCurrentEvent():findParent(GameEvent.Turn, true)
    if turn then
      local phase_data = turn.data.phase_table
      for i, phase in ipairs(phase_data) do
        if phase.phase == Player.Discard and phase.reason == "game_rule" then
          table.insert(phase_data, i + 1, PhaseData:new {
            who = target,
            reason = skel.name,
            phase = Player.Play,
          })
        end
      end
    end
  end,
  can_refresh = function(self, event, target, player, data)
    return data.phase == Player.Play and target == player and player:hasSkill(skel.name) and data.reason == skel.name
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@lb__yingbin-phase", 1)
  end,
})

skel:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    local room = Fk:currentRoom()
    local from = table.find(room.alive_players, function(to)
      return to:hasSkill(skel.name) and to:getMark("@@lb__yingbin-phase") > 0
    end)
    if from then
      return player ~= from
    end
  end,
  prohibit_response = function(self, player, card)
    local room = Fk:currentRoom()
    local from = table.find(room.alive_players, function(to)
      return to:hasSkill(skel.name) and to:getMark("@@lb__yingbin-phase") > 0
    end)
    if from then
      return player ~= from
    end
  end
})

skel:addLoseEffect(function(self, player, is_death)
  player.room:setPlayerMark(player, "@@lb__yingbin-phase", 0)
end)

return skel
